Namespace PeriodProcessing

    ''' <summary>
    ''' Retrieves student satisfied requirements for a Diploma from the database
    ''' </summary>
    ''' <remarks></remarks>
    Public Class DBDiplomaSatisfiedRequirementProvider
        Implements IDiplomaSatisfiedRequirementProvider

        ''' <summary>
        ''' Loads Satisified DiplomaRequirements records for this student
        ''' for a particular diploma type
        ''' </summary>
        ''' <param name="dipType">The diploma type we are looking for requierments satisfied</param>
        ''' <param name="student">The Student we are looking for requierments satisfied</param>
        ''' <returns>List of DiplomaSatisfiedRequirement objects</returns>
        ''' <remarks>Used in PeriodProcessor class</remarks>
        Public Function getStudentDiplomaSatisfiedRequirement(ByVal dipType As DiplomaType, _
                                                                    ByVal student As Student) _
                        As List(Of DiplomaSatisfiedRequirement) Implements IDiplomaSatisfiedRequirementProvider.getStudentDiplomaSatisfiedRequirements

            'load Diplomas satisfied by the student for the Diploma we are
            'checking in a previous period/class
            Dim dbm As New DiplomaSatisfiedRequirementDBMapper()
            Const STR_GET_ALL_PASSED_REQS As String = _
                "DiplomaRequirementId in (" & _
                " select DiplomaRequirementId from DiplomaRequirement where DiplomaTypeId={0}) " & _
                " and CertificationEarnedId in (select CertificationEarnedId from CertificationEarned where studentId={1})"

            Dim lst As List(Of DiplomaSatisfiedRequirement) = dbm. _
                                       findList(STR_GET_ALL_PASSED_REQS, _
                                        dipType.DiplomaTypeId, student.StudentId)

            If student.MemberNumber = PeriodProcessor.TRACK_STUDENT_NUMBER Then
                Trace.TraceInformation("getStudentDiplomaSatisfiedRequirement:" & lst.Count)
            End If

            Return lst


        End Function

    End Class
End Namespace
